// 工作量统计中心
import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';

enum Api {
  listFruit = '/monitoring/infoFruit/list', //获取列表
  save = '/monitoring/infoFruit/add', //新增
  edit = '/monitoring/infoFruit/edit', //编辑
  getFruitInfoById = '/monitoring/infoFruit/queryById', //获取编辑数据
  deleteFruit = '/monitoring/infoFruit/delete',
  deleteBatch = '/monitoring/infoFruit/deleteBatch',
}

/**
 * 列表接口
 * @param params
 */
export const listFruit = (params) => defHttp.get({ url: Api.listFruit, params });
/**
 * 获取编辑数据
 * @param params
 */
export const getFruitInfoById = (params) => defHttp.get({ url: Api.getFruitInfoById, params });

/**
 * 编辑保存
 * @param params
 */
export const saveFruitInfo = (params, isUpdate) => {
  const url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({ url: url, params });
};
/**
 * 删除
 */
export const deleteFruit = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.deleteFruit, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
};
/**
 * 批量删除用户
 * @param params
 */
export const batchDeleteFruit = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
};
